package com.zxlspace.collection;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;

public class TestDemo01 {

    public static void main(String[] args) {
        List arrayList = new ArrayList();  //底层数组, 查询快（根据索引），效率高，插入修改慢，因为要实现重排,线程不安全
        List linkedList = new LinkedList(); //底层链表, 查询慢，效率高，插入修改快（根据链表，知道前后元素位置）,线程不安全
        List vector = new Vector(); //底层数组，线程安全， 效率低

        arrayList.add("aaaa");
        linkedList.add("bbb");
        linkedList.add("bbb");
        vector.add("cccc");
        vector.add("cccc");

        arrayList.remove(2);
        arrayList.set(2, "asas");
        arrayList.add(15, "gggg");

        linkedList.remove(1);
//
//        System.out.println(arrayList);
//        System.out.println(linkedList);
//        System.out.println(vector);

        /*for (int i=0; i<12; i++) {
            arrayList.add("aaaa" + i);
        }*/

        System.out.println(arrayList);

        System.out.println(arrayList.size());

       /* long stime = System.currentTimeMillis();
        System.out.println("当前时间: " + System.currentTimeMillis());

        for (int i=0; i<10000000; i++) {
            arrayList.add("aaa" + i);
        }

        long etime = System.currentTimeMillis();
        long cost = etime-stime;
        System.out.println("结束时间: " + System.currentTimeMillis());
        System.out.println("花费时间: " + cost);
        System.out.println(arrayList.size());*/

        /**********/

       /* long stime1 = System.currentTimeMillis();
        System.out.println("当前时间: " + System.currentTimeMillis());

        for (int i=0; i<10000000; i++) {
            linkedList.add("aaa" + i);
        }

        long etime1 = System.currentTimeMillis();
        long cost1 = etime1-stime1;
        System.out.println("结束时间: " + System.currentTimeMillis());
        System.out.println("花费时间: " + cost1);
        System.out.println(linkedList.size());*/

        /**********/

/*
        long stime2 = System.currentTimeMillis();
        System.out.println("当前时间: " + System.currentTimeMillis());

        for (int i=0; i<10000000; i++) {
            vector.add("aaa" + i);
        }

        long etime2 = System.currentTimeMillis();
        long cost2 = etime2-stime2;
        System.out.println("结束时间: " + System.currentTimeMillis());
        System.out.println("花费时间: " + cost2);
        System.out.println(vector.size());*/

        System.out.println(StringUtils.equals("aaa", "aaa"));

    }

    /*public void testChildList(List list) {
        if (ArrayList.class.isInstance(list.getClass())) {

        }
        long stime = System.currentTimeMillis();
        System.out.println("当前时间: " + System.currentTimeMillis());

        for (int i=0; i<10000000; i++) {
            arrayList.add("aaa" + i);
        }

        long etime = System.currentTimeMillis();
        long cost = etime-stime;
        System.out.println("结束时间: " + System.currentTimeMillis());
        System.out.println("花费时间: " + cost);
        System.out.println(arrayList.size());
    }*/

}
